<#include "../base/basic-page.ftl">
<#include "../common/table.ftl">
<#include "../common/modal.ftl">
<#include "../common/pagination.ftl">
<@page_head>
<link rel="stylesheet" type="text/css" href="/static/lib/select2/css/select2.min.css">
</@page_head>
<@page_body page_title="商品管理" side_active="/admin/goods/list">
    <div class="main-content container-fluid">
        <div class="row">
            <!--Responsive table-->
            <div class="col-sm-12">
                <@card_table>
                    <@card_header table_title="商品库">
                    </@card_header>
                    <@table_filter>
                    </@table_filter>
                    <@card_body>
                        <@table_tools>
                    <button class="btn btn-space btn-primary" id="store-refresh">
                        <i class="icon mdi mdi-refresh"></i>
                        同步商品库
                    </button>
                        <div class="table-search">
                            <label class="search-wrap" for="table-search-input">
                                <input class="form-control form-control-xs"
                                       id="table-search-input"
                                       type="text"
                                       placeholder="请输入搜索关键字">
                            </label>
                            <button class="btn btn-space btn-primary" id="store-refresh">
                                <i class="icon mdi mdi-search"></i>
                                搜索
                            </button>
                        </div>
                        </@table_tools>
                        <@table extra="">
                            <@table_head>
                        <th style="width:5%; text-align: center;">预览图</th>
                        <th style="width:15%;">商品名称</th>
                        <th style="width:5%;" class="number"><a href="?sort=price">价格</a></th>
                        <th style="width:5%;" class="number"><a href="?sort=volume">月销量</a></th>
                        <th style="width:5%;" class="number">优惠券</th>
                        <th style="width:5%;" class="number"><a href="?sort=finalPrice">券后价</a></th>
                        <th style="width:5%;" class="number">佣金</th>
                        <th style="width:5%;" class="number">点击量</th>
                        <th style="width:5%;" class="number">成交量</th>
                        <th style="width:10%;">分类</th>
                        <th style="width:25%;">操作</th>
                            </@table_head>
                            <@table_body>
                                <#list pageData.records as item>
                        <tr>
                            <td>
                                <a href="${(item.materialData.itemUrl)!'#'}" target="_blank">
                                    <img class="goods-img" src="${(item.materialData.pictUrl)!''}">
                                </a>
                            </td>
                            <td>
                                <a href="${(item.materialData.itemUrl)!'#'}" target="_blank" style="color: #404040;">
                                    ${(item.materialData.title)!'过期商品'}
                                </a>
                            </td>
                            <td class="number">
                                ￥${((item.materialData.zkFinalPrice)!0)?string["0.00"]}
                            </td>
                            <td class="number">
                                ${(item.materialData.volume)!0}&nbsp;件
                            </td>
                            <td class="number">
                                ￥${((item.materialData.couponAmount)!0)?string["0.00"]}
                            </td>
                            <td class="number">
                                ￥${((item.materialData.finalMoney)!0)?string["0.00"]}
                            </td>
                            <td class="number cell-detail">
                                <span>￥${((item.materialData.commissionAmount)!0)?string["0.00"]}</span>
                                <span class="cell-detail-description">
                                    ${((item.materialData.commissionRate)!0)?string["0.00"]}%
                                </span>
                            </td>
                            <td class="number">
                                ${(0)}
                            </td>

                            <td class="number">
                                ${(0)}
                            </td>
                            <td>
                                ${item.categoryPathName}
                            </td>
                            <td>
                                <button class="btn btn-rounded btn-space btn-success "
                                        data-toggle="modal"
                                        data-target="#edit-goods-${item.id}">
                                    <i class="icon mdi mdi-border-color"></i>
                                    编辑
                                </button>
                                <button class="btn btn-rounded btn-space btn-secondary"
                                        data-toggle="modal"
                                        data-target="#md-edit-1">
                                    淘口令
                                </button>
                                <button class="btn btn-rounded btn-space btn-secondary"
                                        data-toggle="modal"
                                        data-target="#md-edit-1">
                                    推广文案
                                </button>
                            </td>
                        </tr>
                                </#list>
                            </@table_body>
                        </@table>
                        <@pagination pageData.current,pageData.size,pageData.total>
                        </@pagination>
                    </@card_body>
                </@card_table>
            </div>
        </div>
    </div>
<#list pageData.records as item>
    <@modal id="edit-goods-${item.id}">
        <@modal_header title="编辑商品">
        </@modal_header>
    <form id="form-edit-goods-${item.id}" class="form-edit-goods" novalidate>
        <@modal_body>
        <input name="goodsId" value="${item.id}" style="opacity: 0;display: none;">
        <div class="form-group">
            <label for="goods-category-${(item.category.id)!-1}">商品分类</label>
            <select name="goodsCategoryId" id="goods-category-${(item.category.id)!-1}" category-id="${(item.category.id)!-1}" class="form-control form-control-xs goods-category">
            </select>
        </div>
        <div class="form-group">
            <label for="goods-group-${item.id}">商品分组</label>
            <select name="goodsGroups" id="goods-group-${item.id}"
                    class="select2-hidden-accessible goods-group"
                    group-data="${item.groupIds}"
                    multiple="" tabindex="-1" aria-hidden="true" >

            </select>
        </div>
        </@modal_body>
        <@modal_footer>
        <button class="btn btn-secondary md-close" type="button" data-dismiss="modal">取消</button>
        <button class="btn btn-primary md-close" type="submit">确认</button>
        </@modal_footer>
    </@modal>
</form>
</#list>
</@page_body>
<@page_foot>
<script src="/static/lib/select2/js/select2.min.js" type="text/javascript"></script>
<script src="/static/lib/select2/js/select2.full.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function(){
        //initialize the javascript
        var cli = new S7BuyCli();
        cli.init();
        cli.initGoodsList({
            categoryTree: ${allCategory},
            allGroup:${allGroup}
        });
    });
</script>
</@page_foot>